﻿@model dynamic

@{
    ResFile = "cms_Pages";
}
           
<div class="b-form  b-form_bordered float-left b-form_theme_green">
    <div class="b-form__head">
        <h3 class="b-form__title">@_("Add section to this region")</h3>
    </div>
    <div class="b-form__body">
        <div class="b-form__content b-form__content_auto js-form__content_auto">
            <ol class="b-form__rows ul-reset g-clear">
                <li class="b-form__row g-clear">
                    <a id="addPageContent" rel="@Model.PageId/@Model.CurrentTemplateRegion" href="@Url.Action("addcontent", "cmspage")/@Model.PageId/@Model.CurrentTemplateRegion">@_("Standard content")</a>
                </li>
                <li class="b-form__row g-clear">
                    <a id="addPageSnippet" class="ajax b-fancybox fancybox" rel="@Model.PageId/@Model.CurrentTemplateRegion" data-url="@Url.Action("addsnippet", "cmspage")" data-page="@Model.PageId" data-region="@Model.CurrentTemplateRegion" href="@Url.Action("contentpicker", "cmscontent", new { defaultContentType = "Snippet" })">@_("Snippet")</a>
                </li>
                @(Html.UserGroupPlaceholder().ForUserGroups(PredefinedUserGroups.Developer).Template(
                @<text>
                <li class="b-form__row g-clear">
                    <a id="addPagePartialView" rel="@Model.PageId/@Model.CurrentTemplateRegion" href="@Url.Action("addpartialview", "cmspage")/@Model.PageId/@Model.CurrentTemplateRegion">@_("View control")</a>
                    <div id="addPagePartialViewContainer" class="b-form__content" style="display:none">
                        <ol class="b-form__rows ul-reset g-clear">
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="PartialViewName">@_("Partial view name")</label>
                                <input id="PartialViewName" type="text" class="text reset-me-partial-view-container" name="PartialViewName" />
                            </li>
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="PartialAdministrationViewName">@_("Administration view name")</label>
                                <input id="PartialAdministrationViewName" type="text" class="text reset-me-partial-view-container" name="PartialAdministrationViewName" />
                            </li>
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="PartialModelType">@_("Model type")</label>
                                <input id="PartialModelType" type="text" class="text reset-me-partial-view-container" name="PartialModelType" />
                            </li>
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="ViewCaption">@_("Caption")</label>
                                <input id="ViewCaption" type="text" class="text reset-me-partial-view-container" name="ViewCaption" />
                            </li>
                            <li> 
                                <input id="addPagePartialView-save" class="b-button b-button_small" name="addPagePartialView-save" type="submit" value="@_("Save")" />
                                <input id="addPagePartialView-cancel" class="b-button b-button_small b-button_colour_grey" name="btnCancel" type="submit" value="@_("Cancel")" />
                            </li>
                        </ol>
                    </div>
                </li>
                <li class="b-form__row g-clear">
                    <a id="addPageActionView" rel="@Model.PageId/@Model.CurrentTemplateRegion" href="@Url.Action("addactionview", "cmspage")/@Model.PageId/@Model.CurrentTemplateRegion">@_("Action control")</a>
                    <div id="addPageActionViewContainer" class="b-form__content" style="display:none">
                        <ol class="b-form__rows ul-reset g-clear">
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="ActionController">@_("Controller name")</label>
                                @(Html.Telerik().AutoComplete()
                                        .Name("ActionController")
                                        .Filterable(f => f.FilterMode(AutoCompleteFilterMode.Contains))
                                        .DataBinding(c => c.Ajax().Select("Controllers", "CmsAutocomplete"))
                                        .HtmlAttributes(new { @class = "text reset-me-action-view-container" })
                                )
                            </li>
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="ActionName">@_("Action name")</label>
                                @(Html.Telerik().AutoComplete()
                                      .AutoFill(true)
                                      .Name("ActionName")
                                      .Filterable(f => f.FilterMode(AutoCompleteFilterMode.Contains))
                                      .DataBinding(c => c.Ajax().Select("Actions", "CmsAutocomplete"))
                                      .HtmlAttributes(new { @class = "text reset-me-action-view-container" })
                                      .ClientEvents(c => c.OnDataBinding("onDataBinding")))
                            </li>
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="ActionAdministrationViewName">@_("Administration view name")</label>
                                <input id="ActionAdministrationViewName" type="text" class="text reset-me-action-view-container" name="ActionAdministrationViewName" />
                            </li>
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="PartialModelType">@_("Parameter type")</label>
                                <input id="ActionModelType" type="text" class="text reset-me-action-view-container" name="ActionModelType" />
                            </li>
                            <li class="b-form__row g-clear">
                                <label class="no-margins" for="ActionCaption">@_("Caption")</label>
                                <input id="ActionCaption" type="text" class="text reset-me-partial-view-container" name="ActionCaption" />
                            </li>
                            <li>
                                <input id="addPageActionView-save" class="b-button b-button_small" name="addPageActionView-save" type="submit" value="@_("Save")" />
                                <input id="addPageActionView-cancel" class="b-button b-button_small b-button_colour_grey" name="btnCancel" type="submit" value="@_("Cancel")" />
                            </li>
                        </ol>

                    </div>
                </li>
                <li class="b-form__row g-clear">
                    <a id="addContentModule" rel="@Model.PageId/@Model.CurrentTemplateRegion" href="@Url.Action("addcontentmodule", "cmspage")/@Model.PageId/@Model.CurrentTemplateRegion">@_("Content Module")</a>
                </li>
                </text>)
                .Render())                
            </ol>    		
        </div>
    </div>
</div>
<div class="b-form  b-form_bordered float-right b-form_theme_green">
    <div class="b-form__head">
        <h3 class="b-form__title">@_("Add a module")</h3>
    </div>
    <div class="b-form__body">
        <div class="b-form__content b-form__content_auto js-form__content js-form__module-list">
            @{Html.RenderAction("availableModules", "cmspagecontrol", new { pageId = Model.PageId, templateRegionId = Model.CurrentTemplateRegion });}
        </div>
    </div>
</div>
<div class="clearall"></div>

<script type="text/javascript" src="@Url.Content("~/admin/assets/js/special/jquery.scrollTo-min.js")"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $('.js-form__module-list a.addPageModule').click(function() {
            var myIndex = $(this).parent().prevAll().length + 1;
            $("ol li:nth-child(" + myIndex + ") .js-admin-caption").css("display", "block");
            $('.js-form__module-list').scrollTo('ol li:nth-child(' + myIndex + ') a');
        });
    });

    function onDataBinding(e) {
        e.data = $.extend({}, e.data, { controllerName: $('#ActionController').val() });
    }
</script>